package com.hulk.boot.startup;

import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;

import lombok.extern.slf4j.Slf4j;

/**
 * @author 作者 cmt 类说明
 */

@Slf4j
@SpringBootApplication
@ComponentScan(basePackages = { "com.hulk.boot", "com.hulk.common", "com.hulk.feature",
		"com.hulk.frame","org.hibernate.validator" }, includeFilters = {
				@Filter(type = FilterType.ANNOTATION, value = { com.alibaba.dubbo.config.annotation.Service.class }),
				@Filter(type = FilterType.ANNOTATION, value = {
						com.alibaba.dubbo.config.annotation.Reference.class }) }, excludeFilters = {
								@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
								}) })
public class BootprototypeWebApplication {

  	
/*   public static void main(String[] args) {

		String profile = "local";
		if (args == null || args.length <= 0) {
			profile = "local";
		} else if (Objects.equal("local", args[0])) {
			profile = "local";
		} else if (Objects.equal("product", args[0])) {
			profile = "product";
		} else {
			throw new RuntimeException("profile args is error !!!");
		}
		;
		ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder()
				.sources(BootprototypeWebApplication.class, "classpath:/config/spring/applicationContext.xml")
				.bannerMode(Banner.Mode.OFF).profiles(profile).run(args);

		String activeProfiles = String.valueOf(applicationContext.getEnvironment().getActiveProfiles());
		System.setProperty("spring.profiles.active", activeProfiles);
		log.info("activeProfiles:" +  activeProfiles );

	}*/
	
	
	public static void main(String[] args) {

		//java -jar xxx.jar --spring.profiles.active=test  命令启动具体的环境参数
		ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder()
				.sources(BootprototypeWebApplication.class, "classpath:/config/spring/applicationContext.xml")
				.bannerMode(Banner.Mode.OFF).run(args);

		String [] activeProfiles = applicationContext.getEnvironment().getActiveProfiles();
		System.out.println(activeProfiles);
	    log.info("service started successfully");

	}
	
	
}
